package paqueteBasket;

import java.awt.*;
import java.sql.*;
import java.sql.Connection;

public class Conexion {   
     String bd="basket";
     String login="root";
     String password="";
     String url="jdbc:mysql://localhost/"+bd;
     public Connection conn;

    public Conexion() {}

    public Connection conectarMysql() throws Exception{
       conn=null;
        try{
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn=DriverManager.getConnection(url,login,password);
            if(conn!=null){
                    System.out.println("Conexion a la base de datos"+url+".....OK");
            }
        }
        catch(SQLException ex){
            System.out.println("problemas al conectar");
        }
        catch(ClassNotFoundException ex){
            System.out.println(ex.toString());
        }
       return conn;
    }
}